package com.jingan.nursinghome.regulatory.data;


import com.jingan.nursinghome.regulatory.dialog.micrometertable.CreateMicrometerTableDailog;
import com.jingan.nursinghome.regulatory.http.Http;
import com.jingan.nursinghome.regulatory.model.Jinlaoyuang;
import com.jingan.nursinghome.regulatory.model.Linkup;
import com.jingan.nursinghome.regulatory.model.Qfinfo;
import com.jingan.nursinghome.regulatory.model.Topicinfo;
import com.jingan.nursinghome.regulatory.model.User;


import java.util.ArrayList;
import java.util.List;

import cn.android.support.v7.lib.sin.crown.utils.CacheUtils;
import cn.android.support.v7.lib.sin.crown.utils.JSONObjectUtils;

/**
 * 数据表
 * Created by 彭治铭 on 2017/9/25.
 */

public class MicrometerTable {
    private MicrometerTable() {
        user = new User();
    }

    private static MicrometerTable micrometerTable;

    public static MicrometerTable getInstance() {
        if (micrometerTable == null) {
            micrometerTable = new MicrometerTable();
        }
        return micrometerTable;
    }

    User user;//用户数据

    //用户标志
    public String getUserMark() {
        return "userMark:" + user.getAccount();
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }


    //新千分表数据
    public List<Topicinfo> topicinfoList = new ArrayList<>();

    public List<Topicinfo> getTopicinfoList() {
        return topicinfoList;
    }

    public void setTopicinfoList(List<Topicinfo> topicinfoList) {
        this.topicinfoList.clear();
        this.topicinfoList.addAll(topicinfoList);
    }

    public List<Topicinfo> topicsHostoryQF = new ArrayList<>();//千分表历史整改数据

    public List<Topicinfo> getTopicsHostoryQF() {
        return topicsHostoryQF;
    }

    public void setTopicsHostoryQF(List<Topicinfo> topicsHostoryQF) {
        this.topicsHostoryQF.clear();
        this.topicsHostoryQF.addAll(topicsHostoryQF);
    }

    //敬老院数据标志================================================================================================================================================================================================
    public String getJLYMark() {
        return "jinglaoyuang";//千分表标志+专项表敬老院为标志。
    }

    public static List<Jinlaoyuang> jlys = new ArrayList<>();//敬老院

    //获取敬老院
    public List<Jinlaoyuang> getJlys() {
        if (jlys == null || jlys.size() <= 0) {
            Http.getInstance().getJly();
        }
        return jlys;
    }

    //获取指定敬老院ID
    public String getJlyID(String jlyName) {
        String id = "12";
        for (int i = 0; i < getJlys().size(); i++) {
            if (jlyName.equals(getJlys().get(i).getName())) {
                id = getJlys().get(i).getId();
                break;
            }
        }
        return id;
    }

    //根據id獲取指定敬老院名稱
    public String getJlyName(String jlyID) {
        String jlyName = "";
        if(getJlys()!=null&&jlyID!=null){
            for (int i = 0; i < getJlys().size(); i++) {
                if(getJlys().get(i)!=null&&getJlys().get(i).getId()!=null){
                    if (jlyID.trim().equals(getJlys().get(i).getId().trim())) {
                        jlyName = getJlys().get(i).getName();
                        break;
                    }
                }
            }
        }
        return jlyName;
    }

    //溝通人員数据标志================================================================================================================================================================================================
    public String getLinkUPMark() {
        return "linkup";//千分表标志+专项表敬老院为标志。
    }

    public static List<Linkup> linkups = new ArrayList<>();//主要沟通人员

    //获取主要沟通人员[养老机构人员]
    public List<Linkup> getLinkups() {
        return linkups;
    }

    //评估人员
    public List<Linkup> linkups1 = new ArrayList<>();

    public static List<String> names = new ArrayList<>();

    //获取题目模块
    public List<String> getNames() {
        if (names == null || names.size() <= 0) {
            Http.getInstance().getToplist();
        }
        return names;
    }

    //获取指定联系人ID
    public String getLinkupID(String linkName) {
        String id = "12";
        for (int i = 0; i < getLinkups().size(); i++) {
            if (linkName.equals(getLinkups().get(i).getName())) {
                id = getLinkups().get(i).getId();
                break;
            }
        }
        return id;
    }

    //巡检信息
    private Qfinfo qfinfo;

    public Qfinfo getQfinfo() {
        return qfinfo;
    }

    public void setQfinfo(Qfinfo qfinfo) {
        this.qfinfo = qfinfo;
    }
}
